package com.fivetalks.dao;

import java.util.List;


import org.hibernate.Criteria;
import org.hibernate.criterion.Order;
import org.hibernate.criterion.Restrictions;
import org.springframework.stereotype.Repository;

import com.fivetalks.domain.Board;
import com.fivetalks.repository.hibernate.HibernateGenericRepository;


@Repository(value = "boardDAO")
public class BoardDAO extends HibernateGenericRepository<Board>{
	public List<Board> getBoardList(int pg){
		int startIndex = pg * 5 - 5;
		int endIndex = pg * 5;
		
		// where 조건으로 like 검색, 어떤범위에 있는 것을 읽어오고 싶으면
		Criteria criteria = getCriteria();
		criteria.setFirstResult(startIndex);
		criteria.setMaxResults(endIndex);
		criteria.addOrder(Order.desc("regdate"));
		return criteria.list();		
	}
}
